package com.activemq.spring;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@Slf4j
@Component
public class MyMessageListener implements MessageListener {

    @Override
    public void onMessage(Message message) {
        if (message instanceof TextMessage) {
            try {
                log.error("测试");
                log.info(((TextMessage) message).getText());
            } catch (JMSException e) {
                log.error("出错", e);
            }
        }
        log.info("测试" + message);
    }
}
